-
-
Notifications
You must be signed in to change notification settings - Fork 490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Delete resources when a new working copy is cancelled #8460
base: main
Are you sure you want to change the base?
Delete resources when a new working copy is cancelled #8460
Conversation
core/src/main/java/org/fao/geonet/kernel/datamanager/draft/DraftMetadataUtils.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cancelling the working copy works fine, but with this other use case, which also calls the same method I am having some problems, sometimes files are deleted, but sometimes not.
- Approve a metadata
- Edit it and click the Cancel button in the metadata editor.
Can you check at your end?
I also see some error related to Elasticsearch, but I'm not sure yet, if related to this change or something else:
2024-10-29T15:12:47,663 ERROR [geonetwork.datamanager] - Couldn't cleanup draft 124
org.elasticsearch.client.ResponseException: method [POST], host [http://localhost:9200], URI [/gn-records/_delete_by_query?q=%2Bid%3A124&refresh=true], status line [HTTP/1.1 409 Conflict]
{"took":1,"timed_out":false,"total":1,"deleted":0,"batches":1,"version_conflicts":1,"noops":0,"retries":{"bulk":0,"search":0},"throttled_millis":0,"requests_per_second":-1.0,"throttled_until_millis":0,"failures":[{"index":"gn-records","id":"0e8238e7-22c6-4ba8-a1f2-fb53c04b5aac-draft","cause":{"type":"version_conflict_engine_exception","reason":"[0e8238e7-22c6-4ba8-a1f2-fb53c04b5aac-draft]: version conflict, required seqNo [34], primary term [1]. current document has seqNo [36] and primary term [1]","index_uuid":"7n67lyIxRLWp99agH0HzcA","shard":"0","index":"gn-records"},"status":409}]}
@josegar74 An issue I just found while attempting to test this with It seems that within |
@tylerjmchugh thanks for the feedback, I am also not sure why ISO HNAP seems to work fine and ISO19139 does not. |
@tylerjmchugh I've done additional tests about this case:
and found that for iso19139, the folder is not deleted when the files are used for metadata thumbnails. When they are used only as online resources, I could not reproduce the problem. Can you check at your end with HNAP? When it fails, it caused by the delete in Elasticsearch, the internal identifier that is deleted is fine, but throws this error:
According to the docs: https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
It seems some update is done to the index during the working copy cancelation is causing this issue. |
I've tried these 2 changes:
This doesn't solve the problem
DeleteByQueryRequest request = DeleteByQueryRequest.of(
b -> b.index(new ArrayList<>(Arrays.asList(index)))
.q(query)
.conflicts(Conflicts.Proceed)
.refresh(true)); This solves the problem. I think it can be quite safe to use it. But would like a second opinion from @fxprunayre as this code is used in other places. Also if you know what can make the difference when cancelling the editing of a working copy without thumbnails and with thumbnails to cause the error indicated in the previous comment? Can be related to https://github.com/geonetwork/core-geonetwork/blob/main/core/src/main/java/org/fao/geonet/kernel/search/index/OverviewIndexFieldUpdater.java? |
@josegar74 I have retested and I can confirm that with the changes introduced in this PR the folders are deleted except for thumbnails with iso19139. I also tested HNAP again but even with resources used for thumbnails the elasticsearch error does not occur and the folder is deleted successfully. I'm not sure why there is a difference between the two schemas. |
When a newly created working copy is cancelled the working copy is deleted. The associated resources however are not deleted resulting in orphaned files.
This PR aims to fix this issue by also deleting the associated resources when a new working copy is deleted using the "cancel" button in the editor. This functionality is already present when using the "cancel working copy" button on the record view.
Checklist
main
branch, backports managed with labelREADME.md
filespom.xml
dependency management. Update build documentation with intended library use and library tutorials or documentation